<template>
	<view  class="container container17601">
		<view class="diygw-col-6"> 姓名</view>
		<view class="diygw-col-6"> 学号</view>
		<view class="diygw-col-6"> 学科 </view>
		<view class="diygw-col-6"> 成绩 </view>
		
		<view v-for="(item,index) in printArray" class="flex flex-wrap diygw-col-24 flex12-clz" @click="jump_to(item)">
			<view class="diygw-col-6"> {{item.name}}</view>
			<view class="diygw-col-6"> {{item.code}} </view>
			<view class="diygw-col-6"> {{item.subject}} </view>
			<view class="diygw-col-6"> {{item.grade}} </view>
		</view>
		<view class="version text-grey flex-direction-column flex diygw-col-24 justify-center align-center">
			
		</view>
		<view class="clearfix"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//用户全局信息
				userInfo: {},
				//页面传参
				globalOption: {},
				//自定义全局变量
				globalData: {},
				printArray:[],
				pagesindex:0,
				isBottom:false,
			};
		},
		onShow() {
			this.setCurrentPage(this);
			//this.get_data();
			
		},
		onLoad(option) {
			this.setCurrentPage(this);
			if (option) {
				this.setData({
					globalOption: this.getOption(option)
				});
			}
          //  this.jump_to();
		  this.get_data();
			this.init();
		},
		onReachBottom(){
				    // 触底的时候请求数据，即为上拉加载更多
					if(!this.isbottom){
					 	this.pageindex++;
						this.get_data()
					 	//this.search()
					 }
				    
				        console.log('已加载全部数据')
				   
				},
		methods: {
			async init() {},
			get_data(){
				uni.request({
					url:'http://127.0.0.1:8080/api/demo/test',
					method:'POST',
					data:{
						num:60,
						pageindex:this.pagesindex
					},
					
				}).then((res)=>{
					console.log(res);
					if(res.data.code==1)
					{
						this.printArray=[...this.printArray,...res.data.data];
						if(res.data.data.length<60)
						{
							this.isBottom=true
						}
					}
					
				})
			},
			jump_to(item){
				uni.navigateTo({
					url:'/pages/details/details?name='+item.name+'&code='+item.code+'&subject='+item.subject+'&grade='+item.grade,
				})
			}
			
		}
	};
</script>

<style lang="scss" scoped>
	.container17601 {
		padding-left: 0px;
		padding-right: 0px;

		font-size: 12px;
	}
	.container17601 {
	}
</style>
